package com.kgc.scd.controller;

import com.kgc.scd.service.ExpressService;
import com.kgc.scd.service.IndexPicService;
import com.kgc.scd.util.RequestResult;
import com.kgc.scd.util.ResultBuildUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @program: com.kgc.scd.controller
 * @author: HarryXzy
 * @create: 2022-06-17 12:29
 * @description: 物流管理操作入口
 **/
@RestController
@Api(tags = "23、物流管理操作入口")
public class ExpressController {

    @Autowired
    private ExpressService expressService;


    @ApiOperation(value = "根据订单ID查询物流信息", notes = "根据订单ID查询物流信息")
    // 返回状态说明
    @ApiResponses({
            @ApiResponse(code = 500, message = "系统错误"),
            @ApiResponse(code = 200, message = "成功")
    })
    @PostMapping("/searchExpByOrderId")
    public RequestResult<Object> searchExpByOrderId(@RequestParam(value = "orderId") String orderId) {
        Map<String, Object> result = expressService.searchExpByOrderId(orderId);
        if (result.get("code").equals("200")) {
            return ResultBuildUtil.success(result.get("data"));
        }
        return ResultBuildUtil.fail(result.get("code").toString(), result.get("msg").toString());
    }



    @ApiOperation(value = "发货", notes = "发货")
    // 返回状态说明
    @ApiResponses({
            @ApiResponse(code = 500, message = "系统错误"),
            @ApiResponse(code = 200, message = "成功")
    })
    @PostMapping("/sendOrder")
    public RequestResult<Object> sendOrder(@RequestParam(value = "orderId") String orderId,
                                           @RequestParam(value = "ExpressCor") String ExpressCor,
                                           @RequestParam(value = "ExpressId") String ExpressId) {
        Map<String, Object> result = expressService.sendOrder(orderId,ExpressCor,ExpressId);
        if (result.get("code").equals("200")) {
            return ResultBuildUtil.success(result.get("data"));
        }
        return ResultBuildUtil.fail(result.get("code").toString(), result.get("msg").toString());
    }

}
